type Toptions_Ptext$text = any;

type Toptions_Ptext = {
    text?: Toptions_Ptext$text;
    type?: Tstring_convertersName | 'text';
} & Toptions_COLOR;

@ACcolor
class Ptext extends _CP_<Toptions_Ptext> {
    // ====================================================== 当前控件特殊实现 ====================================================== //

    // ====================================================== 初始化参数 ====================================================== //
    static defaultOptions: Toptions_Ptext = {
        type: 'text',
    };
    protected override options_default(): Toptions_Ptext {
        return Ptext.defaultOptions;
    }
    protected override options_handlers(): Toptions_handlers<Toptions_Ptext> {
        return {
            text: {
                [U.F.argType.any]: U.F.fn.obj
            },
            type: {
                [Etype.string]: U.F.fn.obj
            }
        };
    }
    protected override overloading_mapping(mapping: Toption_key_to_types_mapping<Toptions_Ptext>): Toverloading_mapping<Toptions_Ptext> {
        return [
            [
                { key: 'text', types: mapping.get('text') as Array<string> },
            ],
        ];
    }
    protected override options_checker(options: Toptions_Ptext): void {
        if (Object.prototype.hasOwnProperty.call(options, 'text')) {
            if (options.type === 'text') {
                if (typeof options.text !== 'string') {
                    options.text = '';
                }
            } else {
                options.text = U.stringValue(options.text, options.type);
            }
        } else {
            options.text = '';
        }
    }
    protected override saveDEFAULTKeys(): Array<keyof Toptions_Ptext> {
        if (true === (globalThis as any)['isTest']) {// 测试环境下，保留 text 的 DEFAULT 值。
            return ['text'];
        }
        return [];
    }

    // ====================================================== 创建实例对象 ====================================================== //
    protected override topTag(): string { return 'code'; };
    protected override initializer(): void {
        this.ele.setAttr('textContent', this.options.text as string);
    }
    protected override afterInitializer(): void {
    }
}

interface _IK_ {
    // ========= 创建实例对象（通用） ========= //
    /**
     * 创建控件
     * @returns 控件实例对象
     */
    text(): KHTMLElement;

    /**
     * 创建控件
     * @param options 控件参数
     * @returns 控件实例对象
     */
    text(options: Toptions_Ptext): KHTMLElement;

    // ========= 创建实例对象（特殊） ========= //
    /**
     * 创建控件
     * @param text 文本值
     * @returns 控件实例对象
     */
    text(text: Toptions_Ptext$text): KHTMLElement;
}
{
    K.text = (...args: Array<any>) => { return new Ptext(...args).ele; };
}
